package com.ruoyi.web.controller.workSafetyStandardization.inspection;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.workSafetyStandardization.domain.InspectionTeamMembers;
import com.ruoyi.workSafetyStandardization.service.IInspectionTeamMembersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 考核评委组人员Controller
 *
 * @author pengjie
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/workSafetyStandardization/InspectionMembers")
public class InspectionTeamMembersController extends BaseController
{
    @Autowired
    private IInspectionTeamMembersService inspectionTeamMembersService;

    /**
     * 查询考核评委组人员列表
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMembers:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionTeamMembers inspectionTeamMembers)
    {
        startPage();
        List<InspectionTeamMembers> list = inspectionTeamMembersService.selectInspectionTeamMembersList(inspectionTeamMembers);
        return getDataTable(list);
    }

    /**
     * 导出考核评委组人员列表
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMembers:export')")
    @Log(title = "考核评委组人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionTeamMembers inspectionTeamMembers)
    {
        List<InspectionTeamMembers> list = inspectionTeamMembersService.selectInspectionTeamMembersList(inspectionTeamMembers);
        ExcelUtil<InspectionTeamMembers> util = new ExcelUtil<InspectionTeamMembers>(InspectionTeamMembers.class);
        util.exportExcel(response, list, "考核评委组人员数据");
    }

    /**
     * 获取考核评委组人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMembers:query')")
    @GetMapping(value = "/{inspectionMemberId}")
    public AjaxResult getInfo(@PathVariable("inspectionMemberId") String inspectionMemberId)
    {
        return success(inspectionTeamMembersService.selectInspectionTeamMembersByInspectionMemberId(inspectionMemberId));
    }

    /**
     * 新增考核评委组人员
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMembers:add')")
    @Log(title = "考核评委组人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionTeamMembers inspectionTeamMembers)
    {
        return toAjax(inspectionTeamMembersService.insertInspectionTeamMembers(inspectionTeamMembers));
    }

    /**
     * 修改考核评委组人员
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMembers:edit')")
    @Log(title = "考核评委组人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionTeamMembers inspectionTeamMembers)
    {
        return toAjax(inspectionTeamMembersService.updateInspectionTeamMembers(inspectionTeamMembers));
    }

    /**
     * 删除考核评委组人员
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMembers:remove')")
    @Log(title = "考核评委组人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inspectionMemberIds}")
    public AjaxResult remove(@PathVariable String[] inspectionMemberIds)
    {
        return toAjax(inspectionTeamMembersService.deleteInspectionTeamMembersByInspectionMemberIds(inspectionMemberIds));
    }
}
